/**
 * action
 */

import * as actionTypes from './constants';
import { getTopBanners, getPersonalized } from '@/services/recommend'

const changeBannerListAction = res => ({
  type: actionTypes.CHANGE_BANNER_LIST,
  bannerList: res.banners
});

const changePersonalizedList = res => ({
  type: actionTypes.PERSONALIZED_LIST,
  personalizedList: res.result
})

export const getBannerListAction = () => {
  return dispatch => {
    getTopBanners().then(res => {
      dispatch(changeBannerListAction(res))
    })
  }
}

// 推荐歌单
export const getPersonalizedListAction = (num) => {
  return dispatch => {
    getPersonalized(num).then(res => {
      dispatch(changePersonalizedList(res))
    })
  }
}
